import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:my_app/pages/api_demos/ad_dialog.dart';
import 'package:my_app/pages/api_demos/affix_header_sliver.dart';
import 'package:my_app/pages/api_demos/calendar_date_demo.dart';
import 'package:my_app/pages/api_demos/download_and_install.dart';
import 'package:my_app/pages/api_demos/drageable_demo.dart';
import 'package:my_app/pages/api_demos/expandable_sliver.dart';
import 'package:my_app/pages/api_demos/overlay_test.dart';
import 'package:my_app/pages/api_demos/paint_widget.dart';
import 'package:my_app/pages/api_demos/paint_with_animate.dart';
import 'package:my_app/pages/api_demos/snack_bar_test.dart';

/// 使用dart3.x的增强枚举来集中管理路由地址与页面
/// 
/// 便于使用Ctrl+鼠标左键查看对应页面
/// 
/// 如果有需要，也可增加name选项
enum ApiRouters {
  // demo('/demo'),
  downloadAndInstall('/download-and-install', DownloadInstallPage()),
  snackBarTestPage('/snack-bar-test', SnackBarTestPage()),
  draggableDemo('/draggable-demo', DraggableDemo()),
  overlayTest('/overlay-test', OverlayTestPage()),
  affixHeaderSliver('/affix-header-sliver', AffixHeaderSliverPage()),
  expandableSliver('/expandable-sliver', ExpandableSliverPage()),
  adDialog('/ad-dialog', AdDialogPage()),
  paintWidget('/paint-widget', PaintWidgetPage()),
  paintWithAnimate('/paint-with-animate', PaintWithAnimatePage()),
  calendarDateDemo('/calendar-date-demo', CalendarDateDemoPage()),
  ;

  const ApiRouters(this.path, this.page);

  final String path;
  final Widget page;
}

List<RouteBase> generateApiRoutes(GlobalKey<NavigatorState> rootkey) {
  return ApiRouters.values.map<RouteBase>((e) {
    return GoRoute(
      path: e.path,
      parentNavigatorKey: rootkey,
      builder: (context, state) => e.page,
    );
  }).toList();
  // return <RouteBase> [
  //   GoRoute(
  //     path: ApiRouters.downloadAndInstall.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => ApiRouters.downloadAndInstall.page,
  //   ),
  //   GoRoute(
  //     path: ApiRouters.snackBarTestPage.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => ApiRouters.snackBarTestPage.page,
  //   ),
  //   GoRoute(
  //     path: ApiRouters.draggableDemo.path,
  //     parentNavigatorKey: rootkey,
  //     builder: (context, state) => ApiRouters.draggableDemo.page,
  //   ),
  // ];
}